package nc;

import java.util.Scanner;

public class Q21255 {

    public static int maxValid(String s) {
        // 假设（i，j)是s的一串对称字串，则看(i-1,j+1)是否也是对称字串
        int max = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            int length = 0;
            for (int j = s.length() - 1; j >=i ; j--) {
                if (isValid(s, i, j)) {
                    length = j - i + 1 ;
                    break;
                }
            }
            if (length > max) {
                max = length;
            }
        }
        return max;
    }

    // i <= j
    public static boolean isValid(String s,int i, int j) {
        if (i == j) {
            return true;
        }
        if (s.charAt(i) == s.charAt(j)) {
            if (i == j - 1) {
                return true;
            } else {
                return isValid(s, i+1,j-1);
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            System.out.println(maxValid(s));
        }
    }

}
